--[[

	GModRP - Real Garry's Mod Roleplay.
			By Slob187.
		

]]


local ScoreFrame
 
function GM:ScoreboardShow()


	ScoreFrame = vgui.Create("GMRPFrame")
	ScoreFrame:SetSize(700, 760) 
	ScoreFrame:SetTitle( "Scoreboard" )
	ScoreFrame:SetPos(ScrW() / 2 - ScoreFrame:GetWide() / 2, ScrH() / 2 - ScoreFrame:GetTall() / 2) --:O
	ScoreFrame:SetVisible(true)
	ScoreFrame:SetDraggable(true)
	ScoreFrame:SetBackgroundBlur(true)
	ScoreFrame:ShowCloseButton(false)
	ScoreFrame:MakePopup()
	
	
	local PlayerList = vgui.Create("DPanelList", ScoreFrame)
	PlayerList:SetPos(40, 40)
	PlayerList:SetSize(ScoreFrame:GetWide() - 80, ScoreFrame:GetTall() - 80)
	PlayerList:EnableVerticalScrollbar(true) 
	PlayerList:EnableHorizontal(false) 
	PlayerList:SetSpacing(0)
	PlayerList:SetPadding(10)

	local ScoreHead = vgui.Create("DPanel")
	ScoreHead:SetTall( 50 )
	ScoreHead.Paint = function()
	
		draw.RoundedBox( 6, 0, 0, ScoreHead:GetWide(), ScoreHead:GetTall(), Color( 90, 111, 142, 225 ) )		

	end
	PlayerList:AddItem(ScoreHead)
	
	
	ScoreHead.Title = vgui.Create("DLabel", ScoreHead)
	ScoreHead.Title:SetPos( 90, ScoreHead:GetTall()/2 - ScoreHead.Title:GetTall()/2 )
	ScoreHead.Title:SetText( "Name" )
	ScoreHead.Title:SetFont("GModRPFontOne")
	ScoreHead.Title:SetColor( Color( 180, 180, 180, 255 ) )
	ScoreHead.Title:SizeToContents() 
	ScoreHead.Title:SetContentAlignment( 5 )
	
	ScoreHead.Job = vgui.Create("DLabel", ScoreHead)
	ScoreHead.Job:SetPos( 300, ScoreHead:GetTall()/2 - ScoreHead.Job:GetTall()/2 )
	ScoreHead.Job:SetText( "Job" )
	ScoreHead.Job:SetFont("GModRPFontOne")
	ScoreHead.Job:SetColor( Color( 180, 180, 180, 255 ) )
	ScoreHead.Job:SizeToContents() 
	ScoreHead.Job:SetContentAlignment( 5 )

	ScoreHead.Ping = vgui.Create("DLabel", ScoreHead)
	ScoreHead.Ping:SetPos( 500, ScoreHead:GetTall()/2 - ScoreHead.Ping:GetTall()/2 )
	ScoreHead.Ping:SetText( "Ping" )
	ScoreHead.Ping:SetFont("GModRPFontOne")
	ScoreHead.Ping:SetColor( Color( 180, 180, 180, 255 ) )
	ScoreHead.Ping:SizeToContents() 
	ScoreHead.Ping:SetContentAlignment( 5 )	
	
	
	for _, player in pairs(player.GetAll()) do
	
	
		local PlayerPanel = vgui.Create("DPanel")
		PlayerPanel:SetTall(75)
		PlayerPanel.Paint = function()
		
			draw.RoundedBox( 6, 0, 0, PlayerPanel:GetWide(), PlayerPanel:GetTall(), Color( 180, 180, 180, 255 ) )		
	
		end
		PlayerList:AddItem(PlayerPanel)

		
		PlayerPanel.Icon = vgui.Create("SpawnIcon", PlayerPanel)
		PlayerPanel.Icon:SetModel(player:GetModel())
		PlayerPanel.Icon:SetPos(3, 3)
		PlayerPanel.Icon:SetToolTip( nil )
	
		PlayerPanel.Title = vgui.Create("DLabel", PlayerPanel)
		PlayerPanel.Title:SetPos( 90, PlayerPanel:GetTall() / 2 - PlayerPanel.Title:GetTall() / 2 )
		PlayerPanel.Title:SetText(player:Nick())
		PlayerPanel.Title:SetFont("GModRPFontOne")
		PlayerPanel.Title:SetColor( Color( 90, 111, 142, 225 ) )
		PlayerPanel.Title:SizeToContents() 
 		PlayerPanel.Title:SetContentAlignment( 5 )
		
		PlayerPanel.Job = vgui.Create("DLabel", PlayerPanel)
		PlayerPanel.Job:SetPos( 300, PlayerPanel:GetTall() / 2 - PlayerPanel.Job:GetTall() / 2 )
		PlayerPanel.Job:SetText( player:getJob() )
		PlayerPanel.Job:SetFont("GModRPFontOne")
		PlayerPanel.Job:SetColor( Color( 90, 111, 142, 225 ) )
		PlayerPanel.Job:SizeToContents() 
 		PlayerPanel.Job:SetContentAlignment( 5 )

		PlayerPanel.Ping = vgui.Create("DLabel", PlayerPanel)
		PlayerPanel.Ping:SetPos( 500, PlayerPanel:GetTall() / 2 - PlayerPanel.Ping:GetTall() / 2 )
		PlayerPanel.Ping:SetText( player:Ping() )
		PlayerPanel.Ping:SetFont("GModRPFontOne")
		PlayerPanel.Ping:SetColor( Color( 90, 111, 142, 225 ) )
		PlayerPanel.Ping:SizeToContents() 
 		PlayerPanel.Ping:SetContentAlignment( 5 )			
		
	end
	
	return true
	
end


function GM:ScoreboardHide()

	ScoreFrame:Close()
	return true
	
end